package com.example.baselibrary.rx;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import retrofit2.Response;

/**
 * by zqq on 2018/6/12.
 */

public class BaseResponseTransformer<V, T> implements ObservableTransformer<Response<V>, V> {

    @Override
    public ObservableSource<V> apply(Observable<Response<V>> upstream) {
        return upstream.subscribeOn(Schedulers.io())
                .flatMap(new BaseResponseFunc<V, T>())
                .observeOn(AndroidSchedulers.mainThread());
    }
}
